from django.db import models
from role.models import Role
from dept.models import Dept


# Create your models here.
class User(models.Model):
    username = models.CharField(max_length=20, unique=True, verbose_name='用户名')
    password = models.CharField(max_length=150, verbose_name='密码')
    # 昵称
    nick_name = models.CharField(max_length=50, verbose_name='昵称', default='nick_name')
    # 头像
    avatar = models.CharField(max_length=255, verbose_name='用户头像',
                              default='https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif')
    # 用户状态  0  禁用  1 可用  is_active
    is_active = models.SmallIntegerField(choices=((0, '禁用'), (1, '正常')), default=1, verbose_name='用户状态')
    email = models.CharField(unique=True, verbose_name='邮箱', max_length=50)
    age = models.SmallIntegerField(verbose_name='年龄', default=18)
    # 角色
    role = models.ForeignKey(Role, on_delete=models.PROTECT)
    # 部门
    dept = models.ForeignKey(Dept, on_delete=models.PROTECT)

    create_time = models.DateTimeField(auto_now_add=True)

    class Meta:
        db_table = 'user'
